package com.luo.chengrui.module.sa.job.org;

import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import com.luo.chengrui.module.sa.service.org.OrgAndPersonSyncService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 组织和人员同步至 system_dept 和system_user表中。
 *
 * @author
 * @version 1.0.0
 * @description
 * @createTime 2023/08/17
 */
@Component
@TenantJob // 多租户
public class OrgAndPersonSyncJob {
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Resource
    OrgAndPersonSyncService orgAndPersonSyncService;

    @XxlJob("saOrgAndPersonSyncXxlJob")
    public ReturnT<String> saOrgAndPersonSyncXxlJob(String param) throws Exception {

        //同步组织
        orgAndPersonSyncService.orgSync();

        //同步人员
        orgAndPersonSyncService.personSync();

        // 返回执行成功
        return ReturnT.SUCCESS;
    }
}
